﻿package mortal.game.net.command
{
    import Framework.MQ.*;
    import Message.Public.*;
    import extend.language.*;
    import mortal.common.net.*;
    import mortal.component.gconst.*;
    import mortal.game.manager.*;
    import mortal.game.manager.msgTip.*;
    import mortal.game.mvc.*;
    import mortal.game.net.broadCast.*;
    import mortal.game.resource.*;
    import mortal.game.scene3D.display3d.text3d.staticText3d.*;
    import mortal.game.scene3D.display3d.text3d.staticText3d.action.*;
    import mortal.game.scene3D.player.entity.*;
    import mortal.game.view.arena.util.*;
    import mortal.game.view.heroArena.util.*;
    import mortal.game.view.lotteryDraw.*;
    import mortal.mvc.core.*;

    public class MoneyUpdateCommand extends BroadCastCall
    {
        private var _isMoneyUpdate:Boolean = false;
        private var _code:int;

        public function MoneyUpdateCommand(param1:Object)
        {
            super(param1);
            return;
        }// end function

        override public function call(param1:MessageBlock) : void
        {
            var _loc_3:SAttributeUpdate = null;
            var _loc_2:* = param1.messageBase as SSeqAttributeUpdate;
            this._code = _loc_2.code;
            for each (_loc_3 in _loc_2.updates)
            {
                
                this.moneyUpdate(_loc_3, _loc_2.code);
                this._isMoneyUpdate = true;
            }
            if (this._isMoneyUpdate)
            {
                CallLater.addCallBack(this.onMoneyUpdateHandler);
                this._isMoneyUpdate = false;
            }
            return;
        }// end function

        private function onMoneyUpdateHandler() : void
        {
            NetDispatcher.dispatchCmd(ServerCommand.MoneyUpdate, _cache.role.money);
            this._isMoneyUpdate = true;
            return;
        }// end function

        protected function flyText(param1:String, param2:int) : void
        {
            var _loc_5:String = null;
            var _loc_3:* = new ActionVo();
            _loc_3.reInit(2, 0, 0, 0, 0, false, false);
            var _loc_4:* = RolePlayer.hasInstacne() && RolePlayer.instance.bodyPlayer;
            if (_loc_4)
            {
                _loc_5 = param1 + "+" + param2;
                SText3DFactory.instance.createtext3D(_loc_5, 0, RolePlayer.instance.bodyPlayer, _loc_3);
            }
            return;
        }// end function

        private function moneyUpdate(param1:SAttributeUpdate, param2:int) : void
        {
            var _loc_4:String = null;
            var _loc_5:String = null;
            var _loc_6:int = 0;
            var _loc_10:int = 0;
            var _loc_11:int = 0;
            var _loc_12:int = 0;
            var _loc_13:int = 0;
            var _loc_14:int = 0;
            var _loc_15:int = 0;
            var _loc_3:* = ConstConfig.instance.getOutUpdateStrByCode(param2);
            var _loc_7:String = "";
            var _loc_8:String = "";
            var _loc_9:String = "";
            switch(param1.attribute.__value)
            {
                case EEntityAttribute._EAttributeCoin:
                {
                    _loc_12 = param1.value - _cache.role.money.coin;
                    _cache.role.money.coin = param1.value;
                    if (_loc_12 > 0)
                    {
                        _loc_9 = Language.getStringByParam(30013, _loc_12.toString());
                        MsgManager.addTipText(_loc_9, MsgHistoryType.GetMsg);
                        this.flyText(Language.getString(20533), _loc_12);
                    }
                    else if (_loc_12 < 0)
                    {
                        _loc_9 = Language.getStringByParam(30014, Math.abs(_loc_12).toString());
                        MsgManager.addTipText(_loc_9, MsgHistoryType.LostMsg);
                    }
                    NetDispatcher.dispatchCmd(ServerCommand.CoinUpdate, _cache.role.money);
                    break;
                }
                case EEntityAttribute._EAttributeCoinBind:
                {
                    _loc_13 = param1.value - _cache.role.money.coinBind;
                    _cache.role.money.coinBind = param1.value;
                    if (_loc_13 > 0)
                    {
                        _loc_9 = Language.getStringByParam(30015, _loc_13.toString());
                        MsgManager.addTipText(_loc_9, MsgHistoryType.GetMsg);
                        this.flyText(Language.getString(20533), _loc_13);
                        if (this._code == UpdateCode.EUpdateCodeBossDrop)
                        {
                            NetDispatcher.dispatchCmd(ServerCommand.GodLuckGiftCollectUpdate, {type:"coin", value:_loc_13});
                        }
                    }
                    else if (_loc_13 < 0)
                    {
                        _loc_9 = Language.getStringByParam(30016, Math.abs(_loc_13).toString());
                        MsgManager.addTipText(_loc_9, MsgHistoryType.LostMsg);
                    }
                    NetDispatcher.dispatchCmd(ServerCommand.CoinUpdate, _cache.role.money);
                    break;
                }
                case EEntityAttribute._EAttributeGold:
                {
                    _loc_14 = param1.value - _cache.role.money.gold;
                    _cache.role.money.gold = param1.value;
                    if (_loc_14 > 0)
                    {
                        _loc_9 = Language.getStringByParam(30017, _loc_14.toString());
                        MsgManager.addTipText(_loc_9, MsgHistoryType.GetMsg);
                        this.flyText(Language.getString(20534), _loc_14);
                    }
                    else if (_loc_14 < 0)
                    {
                        _loc_9 = Language.getStringByParam(30018, Math.abs(_loc_14).toString());
                        MsgManager.addTipText(_loc_9, MsgHistoryType.LostMsg);
                    }
                    NetDispatcher.dispatchCmd(ServerCommand.GoldUpdate, _cache.role.money);
                    break;
                }
                case EEntityAttribute._EAttributeGoldBind:
                {
                    _loc_15 = param1.value - _cache.role.money.goldBind;
                    _cache.role.money.goldBind = param1.value;
                    if (_loc_15 > 0)
                    {
                        _loc_9 = Language.getStringByParam(30019, _loc_15.toString());
                        MsgManager.addTipText(_loc_9, MsgHistoryType.GetMsg);
                        this.flyText(Language.getString(20534), _loc_15);
                        if (this._code == UpdateCode.EUpdateCodeBossDrop)
                        {
                            NetDispatcher.dispatchCmd(ServerCommand.GodLuckGiftCollectUpdate, {type:"gold", value:_loc_15});
                        }
                    }
                    else if (_loc_15 < 0)
                    {
                        _loc_9 = Language.getStringByParam(30020, Math.abs(_loc_15).toString());
                        MsgManager.addTipText(_loc_9, MsgHistoryType.LostMsg);
                    }
                    NetDispatcher.dispatchCmd(ServerCommand.GoldUpdate, _cache.role.money);
                    break;
                }
                case EEntityAttribute._EAttributeSkillPoint:
                {
                    _loc_10 = param1.value - _cache.role.money.skillPoint;
                    _cache.role.money.skillPoint = param1.value;
                    if (_loc_10 > 0)
                    {
                        _loc_9 = Language.getStringByParam(20535, _loc_10);
                        MsgManager.addTipText(_loc_9, MsgHistoryType.GetMsg);
                    }
                    else if (_loc_11 < 0)
                    {
                        _loc_9 = Language.getStringByParam(20536, Math.abs(_loc_10).toString());
                        MsgManager.addTipText(_loc_9, MsgHistoryType.LostMsg);
                    }
                    NetDispatcher.dispatchCmd(ServerCommand.SkillPointUpdate, _cache.role.money);
                    break;
                }
                case EEntityAttribute._EAttributeVitalEnergy:
                {
                    _loc_11 = param1.value - _cache.role.money.vitalEnergy;
                    _cache.role.money.vitalEnergy = param1.value;
                    if (_loc_11 > 0)
                    {
                        _loc_9 = Language.getStringByParam(20118, _loc_11.toString());
                        MsgManager.addTipText(_loc_9, MsgHistoryType.GetMsg);
                        if (param2 == UpdateCode.EUpdateCodeZazen)
                        {
                            NetDispatcher.dispatchCmd(ServerCommand.ZazenGetEnergy, _loc_11);
                        }
                        else if (param2 == UpdateCode.EUpdateCodeSunBath)
                        {
                            _cache.copy.sunbath.addVitalEnergy(_loc_11);
                            NetDispatcher.dispatchCmd(ServerCommand.SunbathInfoViewUpdate, null);
                        }
                        NetDispatcher.dispatchCmd(ServerCommand.VitalEnergyUpdate, _cache.role.money);
                        this.flyText(Language.getString(20537), _loc_11);
                    }
                    else if (_loc_11 < 0)
                    {
                        _loc_9 = Language.getStringByParam(20119, Math.abs(_loc_11).toString());
                        MsgManager.addTipText(_loc_9, MsgHistoryType.LostMsg);
                    }
                    break;
                }
                case EEntityAttribute._EAttributeRunicPower:
                {
                    _loc_6 = param1.value - _cache.role.money.runicPower;
                    _cache.role.money.runicPower = param1.value;
                    if (_loc_6 > 0)
                    {
                        _loc_9 = Language.getStringByParam(20222, _loc_6.toString());
                    }
                    else if (_loc_6 < 0)
                    {
                        _loc_9 = Language.getStringByParam(20223, Math.abs(_loc_6).toString());
                    }
                    NetDispatcher.dispatchCmd(ServerCommand.RunePowerUpdate, _cache.role.money);
                    break;
                }
                case EEntityAttribute._EAttributeHonorAdd:
                {
                    _loc_6 = param1.value - _cache.role.money.honor;
                    _cache.role.money.honor = param1.value;
                    if (_loc_6 > 0)
                    {
                        _loc_9 = Language.getStringByParam(11100, _loc_6.toString());
                        MsgManager.addTipText(_loc_9, MsgHistoryType.GetMsg);
                        this.flyText(Language.getString(20538), _loc_6);
                    }
                    else if (_loc_6 < 0)
                    {
                        _loc_9 = Language.getStringByParam(11101, Math.abs(_loc_6).toString());
                        MsgManager.addTipText(_loc_9, MsgHistoryType.LostMsg);
                    }
                    NetDispatcher.dispatchCmd(ServerCommand.HonorUpdate, _cache.role.money);
                    break;
                }
                case EEntityAttribute._EAttributeExploitAdd:
                {
                    _loc_6 = param1.value - _cache.role.money.exploit;
                    _cache.role.money.exploit = param1.value;
                    if (_loc_6 > 0)
                    {
                        _loc_9 = Language.getStringByParam(11102, _loc_6.toString());
                        MsgManager.addTipText(_loc_9, MsgHistoryType.GetMsg);
                    }
                    else if (_loc_6 < 0)
                    {
                        _loc_9 = Language.getStringByParam(11103, Math.abs(_loc_6).toString());
                        MsgManager.addTipText(_loc_9, MsgHistoryType.LostMsg);
                    }
                    NetDispatcher.dispatchCmd(ServerCommand.ExploitUpdate, _cache.role.money);
                    break;
                }
                case EEntityAttribute._EAttributeArenaGoldNote:
                {
                    _loc_6 = param1.value - _cache.role.money.arena;
                    _cache.role.money.arena = param1.value;
                    if (_loc_6 > 0)
                    {
                        this.flyText(Language.getString(20539), _loc_6);
                        _loc_9 = Language.getStringByParam(11104, _loc_6.toString());
                        MsgManager.addTipText(_loc_9, MsgHistoryType.GetMsg);
                    }
                    else if (_loc_6 < 0)
                    {
                        _loc_9 = Language.getStringByParam(11105, Math.abs(_loc_6).toString());
                        MsgManager.addTipText(_loc_9, MsgHistoryType.LostMsg);
                    }
                    NetDispatcher.dispatchCmd(ServerCommand.ArenaGoldUpdate, _cache.role.money);
                    break;
                }
                case EEntityAttribute._EAttributeAchieve:
                {
                    _loc_6 = param1.value - _cache.role.money.achieve;
                    _cache.role.money.achieve = param1.value;
                    if (_loc_6 > 0)
                    {
                        _loc_9 = Language.getStringByParam(30097, _loc_6.toString());
                        MsgManager.addTipText(_loc_9, MsgHistoryType.GetMsg);
                    }
                    else if (_loc_6 < 0)
                    {
                    }
                    NetDispatcher.dispatchCmd(ServerCommand.AchievementPointUpdate, _cache.role.money);
                    break;
                }
                case EEntityAttribute._EAttributeArenaBronze:
                {
                    _loc_12 = param1.value - _cache.role.money.arenaBronze;
                    _cache.role.money.arenaBronze = param1.value;
                    if (_loc_12 > 0)
                    {
                        _loc_9 = Language.getStringByParam(ArenaUtil.getStrCode(param1.attribute.__value), _loc_12.toString());
                        MsgManager.addTipText(_loc_9, MsgHistoryType.GetMsg);
                        this.flyText(Language.getString(20533), _loc_12);
                    }
                    else if (_loc_12 < 0)
                    {
                        _loc_9 = Language.getStringByParam(ArenaUtil.getStrCode(param1.attribute.__value, false), Math.abs(_loc_12).toString());
                        MsgManager.addTipText(_loc_9, MsgHistoryType.LostMsg);
                    }
                    break;
                }
                case EEntityAttribute._EAttributeArenaSilver:
                {
                    _loc_12 = param1.value - _cache.role.money.arenaSilver;
                    _cache.role.money.arenaSilver = param1.value;
                    if (_loc_12 > 0)
                    {
                        _loc_9 = Language.getStringByParam(ArenaUtil.getStrCode(param1.attribute.__value), _loc_12.toString());
                        MsgManager.addTipText(_loc_9, MsgHistoryType.GetMsg);
                        this.flyText(Language.getString(20533), _loc_12);
                    }
                    else if (_loc_12 < 0)
                    {
                        _loc_9 = Language.getStringByParam(ArenaUtil.getStrCode(param1.attribute.__value, false), Math.abs(_loc_12).toString());
                        MsgManager.addTipText(_loc_9, MsgHistoryType.LostMsg);
                    }
                    break;
                }
                case EEntityAttribute._EAttributeArenaGold:
                {
                    _loc_12 = param1.value - _cache.role.money.arenaGold;
                    _cache.role.money.arenaGold = param1.value;
                    if (_loc_12 > 0)
                    {
                        _loc_9 = Language.getStringByParam(ArenaUtil.getStrCode(param1.attribute.__value), _loc_12.toString());
                        MsgManager.addTipText(_loc_9, MsgHistoryType.GetMsg);
                        this.flyText(Language.getString(20533), _loc_12);
                    }
                    else if (_loc_12 < 0)
                    {
                        _loc_9 = Language.getStringByParam(ArenaUtil.getStrCode(param1.attribute.__value, false), Math.abs(_loc_12).toString());
                        MsgManager.addTipText(_loc_9, MsgHistoryType.LostMsg);
                    }
                    break;
                }
                case EEntityAttribute._EAttributeArenaJewel:
                {
                    _loc_12 = param1.value - _cache.role.money.arenaJewel;
                    _cache.role.money.arenaJewel = param1.value;
                    if (_loc_12 > 0)
                    {
                        _loc_9 = Language.getStringByParam(ArenaUtil.getStrCode(param1.attribute.__value), _loc_12.toString());
                        MsgManager.addTipText(_loc_9, MsgHistoryType.GetMsg);
                        this.flyText(Language.getString(20533), _loc_12);
                    }
                    else if (_loc_12 < 0)
                    {
                        _loc_9 = Language.getStringByParam(ArenaUtil.getStrCode(param1.attribute.__value, false), Math.abs(_loc_12).toString());
                        MsgManager.addTipText(_loc_9, MsgHistoryType.LostMsg);
                    }
                    break;
                }
                case EEntityAttribute._EAttributeArenaSJewel:
                {
                    _loc_12 = param1.value - _cache.role.money.arenaSJewel;
                    _cache.role.money.arenaSJewel = param1.value;
                    if (_loc_12 > 0)
                    {
                        _loc_9 = Language.getStringByParam(ArenaUtil.getStrCode(param1.attribute.__value), _loc_12.toString());
                        MsgManager.addTipText(_loc_9, MsgHistoryType.GetMsg);
                        this.flyText(Language.getString(20533), _loc_12);
                    }
                    else if (_loc_12 < 0)
                    {
                        _loc_9 = Language.getStringByParam(ArenaUtil.getStrCode(param1.attribute.__value, false), Math.abs(_loc_12).toString());
                        MsgManager.addTipText(_loc_9, MsgHistoryType.LostMsg);
                    }
                    break;
                }
                case EEntityAttribute._EAttributeGoldPoint50:
                {
                    _loc_12 = param1.value - _cache.role.money.goldPoint50;
                    _cache.role.money.goldPoint50 = param1.value;
                    if (_loc_12 > 0)
                    {
                        _loc_9 = Language.getStringByParam(lotteryDrawUtil.getStrCode(param1.attribute.__value), _loc_12.toString());
                        MsgManager.addTipText(_loc_9, MsgHistoryType.GetMsg);
                        this.flyText(Language.getString(20533), _loc_12);
                    }
                    else if (_loc_12 < 0)
                    {
                        _loc_9 = Language.getStringByParam(lotteryDrawUtil.getStrCode(param1.attribute.__value, false), Math.abs(_loc_12).toString());
                        MsgManager.addTipText(_loc_9, MsgHistoryType.LostMsg);
                    }
                    break;
                }
                case EEntityAttribute._EAttributeGoldPoint70:
                {
                    _loc_12 = param1.value - _cache.role.money.goldPoint70;
                    _cache.role.money.goldPoint70 = param1.value;
                    if (_loc_12 > 0)
                    {
                        _loc_9 = Language.getStringByParam(lotteryDrawUtil.getStrCode(param1.attribute.__value), _loc_12.toString());
                        MsgManager.addTipText(_loc_9, MsgHistoryType.GetMsg);
                        this.flyText(Language.getString(20533), _loc_12);
                    }
                    else if (_loc_12 < 0)
                    {
                        _loc_9 = Language.getStringByParam(lotteryDrawUtil.getStrCode(param1.attribute.__value, false), Math.abs(_loc_12).toString());
                        MsgManager.addTipText(_loc_9, MsgHistoryType.LostMsg);
                    }
                    break;
                }
                case EEntityAttribute._EAttributeGoldPoint90:
                {
                    _loc_12 = param1.value - _cache.role.money.goldPoint90;
                    _cache.role.money.goldPoint90 = param1.value;
                    if (_loc_12 > 0)
                    {
                        _loc_9 = Language.getStringByParam(lotteryDrawUtil.getStrCode(param1.attribute.__value), _loc_12.toString());
                        MsgManager.addTipText(_loc_9, MsgHistoryType.GetMsg);
                        this.flyText(Language.getString(20533), _loc_12);
                    }
                    else if (_loc_12 < 0)
                    {
                        _loc_9 = Language.getStringByParam(lotteryDrawUtil.getStrCode(param1.attribute.__value, false), Math.abs(_loc_12).toString());
                        MsgManager.addTipText(_loc_9, MsgHistoryType.LostMsg);
                    }
                    break;
                }
                case EEntityAttribute._EAttributeArena2Bronze:
                {
                    _loc_12 = param1.value - _cache.role.money.arena2Bronze;
                    _cache.role.money.arena2Bronze = param1.value;
                    if (_loc_12 > 0)
                    {
                        _loc_9 = Language.getStringByParam(HeroArenaUtil.getStrCode(param1.attribute.__value), _loc_12.toString());
                        MsgManager.addTipText(_loc_9, MsgHistoryType.GetMsg);
                        this.flyText(Language.getString(20533), _loc_12);
                    }
                    else if (_loc_12 < 0)
                    {
                        _loc_9 = Language.getStringByParam(HeroArenaUtil.getStrCode(param1.attribute.__value, false), Math.abs(_loc_12).toString());
                        MsgManager.addTipText(_loc_9, MsgHistoryType.LostMsg);
                    }
                    break;
                }
                case EEntityAttribute._EAttributeArena2Silver:
                {
                    _loc_12 = param1.value - _cache.role.money.arena2Silver;
                    _cache.role.money.arena2Silver = param1.value;
                    if (_loc_12 > 0)
                    {
                        _loc_9 = Language.getStringByParam(HeroArenaUtil.getStrCode(param1.attribute.__value), _loc_12.toString());
                        MsgManager.addTipText(_loc_9, MsgHistoryType.GetMsg);
                        this.flyText(Language.getString(20533), _loc_12);
                    }
                    else if (_loc_12 < 0)
                    {
                        _loc_9 = Language.getStringByParam(HeroArenaUtil.getStrCode(param1.attribute.__value, false), Math.abs(_loc_12).toString());
                        MsgManager.addTipText(_loc_9, MsgHistoryType.LostMsg);
                    }
                    break;
                }
                case EEntityAttribute._EAttributeArena2Gold:
                {
                    _loc_12 = param1.value - _cache.role.money.arena2Gold;
                    _cache.role.money.arena2Gold = param1.value;
                    if (_loc_12 > 0)
                    {
                        _loc_9 = Language.getStringByParam(HeroArenaUtil.getStrCode(param1.attribute.__value), _loc_12.toString());
                        MsgManager.addTipText(_loc_9, MsgHistoryType.GetMsg);
                        this.flyText(Language.getString(20533), _loc_12);
                    }
                    else if (_loc_12 < 0)
                    {
                        _loc_9 = Language.getStringByParam(HeroArenaUtil.getStrCode(param1.attribute.__value, false), Math.abs(_loc_12).toString());
                        MsgManager.addTipText(_loc_9, MsgHistoryType.LostMsg);
                    }
                    break;
                }
                case EEntityAttribute._EAttributeArena2Jewel:
                {
                    _loc_12 = param1.value - _cache.role.money.arena2Jewel;
                    _cache.role.money.arena2Jewel = param1.value;
                    if (_loc_12 > 0)
                    {
                        _loc_9 = Language.getStringByParam(HeroArenaUtil.getStrCode(param1.attribute.__value), _loc_12.toString());
                        MsgManager.addTipText(_loc_9, MsgHistoryType.GetMsg);
                        this.flyText(Language.getString(20533), _loc_12);
                    }
                    else if (_loc_12 < 0)
                    {
                        _loc_9 = Language.getStringByParam(HeroArenaUtil.getStrCode(param1.attribute.__value, false), Math.abs(_loc_12).toString());
                        MsgManager.addTipText(_loc_9, MsgHistoryType.LostMsg);
                    }
                    break;
                }
                case EEntityAttribute._EAttributeArena2SJewel:
                {
                    _loc_12 = param1.value - _cache.role.money.arena2SJewel;
                    _cache.role.money.arena2SJewel = param1.value;
                    if (_loc_12 > 0)
                    {
                        _loc_9 = Language.getStringByParam(HeroArenaUtil.getStrCode(param1.attribute.__value), _loc_12.toString());
                        MsgManager.addTipText(_loc_9, MsgHistoryType.GetMsg);
                        this.flyText(Language.getString(20533), _loc_12);
                    }
                    else if (_loc_12 < 0)
                    {
                        _loc_9 = Language.getStringByParam(HeroArenaUtil.getStrCode(param1.attribute.__value, false), Math.abs(_loc_12).toString());
                        MsgManager.addTipText(_loc_9, MsgHistoryType.LostMsg);
                    }
                    break;
                }
                default:
                {
                    break;
                }
            }
            return;
        }// end function

    }
}
